package com.tengju.bff.interfaces.covercharge.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * @author liang_shi
 * @date 2020/9/1 16:45
 * @description 服务费账户类型
 */
@Getter
@AllArgsConstructor
public enum ServiceAccountTypeEnum {

    /**
     * 客户收益账户
     */
    CUSTOMER_TYPE(1, "ABM", "客户收益账户", "偕创"),

    MANAGE_TYPE(2, "DT", "管理收益账户", "智炬网络"),


    ;

    private Integer code;
    private String platform;
    private String desc;
    private String merchant;


    /**
     * 根据编码获取指定枚举
     *
     * @param code 编码
     * @return 结果
     */
    public static ServiceAccountTypeEnum getInstance(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }
        for (ServiceAccountTypeEnum typeEnum : ServiceAccountTypeEnum.values()) {
            if (typeEnum.getCode().equals(code)) {
                return typeEnum;
            }
        }
        return null;
    }


    /**
     * 根据平台获取指定枚举
     *
     * @param platform 平台
     * @return 结果
     */
    public static ServiceAccountTypeEnum getInstance(String platform) {
        if (StringUtils.isBlank(platform)) {
            return null;
        }
        for (ServiceAccountTypeEnum typeEnum : ServiceAccountTypeEnum.values()) {
            if (typeEnum.getPlatform().equals(platform)) {
                return typeEnum;
            }
        }
        return null;
    }

}
